package com.kingyea.app.market.syncMission.controller;

import com.kingyea.app.market.syncMission.bean.SyncMission;
import com.kingyea.app.market.syncMission.service.SyncMissionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author
 * @version v1.0.0
 * @description SyncMission 控制层
 * @date Created in 2018-03-22 17:48:12
 */
@RequestMapping(value = "/syncMission")
@RestController
public class SyncMissionController {

    private static final Logger LOGGER = LoggerFactory.getLogger(SyncMissionController.class);

    @Autowired
    private SyncMissionService syncMissionService;

    /**
     * 查询全部
     *
     * @param
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public List<SyncMission> list() throws Exception {
        return syncMissionService.list(null);
    }

    /**
     * 通过ID查找对象
     *
     * @return
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public SyncMission detail(@PathVariable String id) throws Exception {
        return syncMissionService.getById(id);
    }

    /**
     * 创建
     *
     * @param syncMission
     * @return
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public Object create(@RequestBody SyncMission syncMission) throws Exception {
        return syncMissionService.save(syncMission);
    }

    /**
     * 更新
     *
     * @param syncMission
     * @return
     */
    @RequestMapping(method = RequestMethod.PUT)
    public SyncMission update(@RequestBody SyncMission syncMission) throws Exception {
        return syncMissionService.update(syncMission);
    }

    /**
     * 删除
     *
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    public int delete(@PathVariable String id) throws Exception {
        return syncMissionService.deleteById(id);
    }

    /**
     * 任务列表
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/taskList", method = RequestMethod.POST)
    public Object taskList(@RequestBody Map<String, Object> syncMissionListVo) throws Exception {
        return syncMissionService.taskList(syncMissionListVo);

    }

}
